import 'package:flutter/material.dart';
import 'package:huobi/configs/app_style_config.dart';
import 'package:huobi/model/homePage/zfb_cell_model.dart';
import 'package:huobi/routers/app_routers.dart';
import 'package:huobi/routers/hb_router.dart';
import 'package:huobi/views/homePage/zfb_cell_widget.dart';
import 'package:huobi/views/homePage/phb_title_cell_widget.dart';

class ZfbPage extends StatefulWidget {
  @override
  _ZfbPageState createState() => _ZfbPageState();
}

class _ZfbPageState extends State<ZfbPage> {

  List dataSource = [
    {"name": "DF", "unit": "USDT", "price": "0.9663", "applies": 30.80},
    {"name": "GNX", "unit": "USDT", "price": "0.032923", "applies": 23.06},
    {"name": "FLOW", "unit": "USDT", "price": "28.7186", "applies": -16.27},
    {"name": "NSURE", "unit": "USDT", "price": "1.0122", "applies": 14.74},
    {"name": "WOO", "unit": "USDT", "price": "0.35364", "applies": 13.88},
    {"name": "WOO", "unit": "USDT", "price": "0.00064350", "applies": -12.96},
    {"name": "VALUE", "unit": "USDT", "price": "5.7019", "applies": 12.47},
    {"name": "SNC", "unit": "USDT", "price": "0.00000084", "applies": -11.99},
    {"name": "BADGER", "unit": "USDT", "price": "49.1994", "applies": 11.56},
    {"name": "SUSHI", "unit": "USDT", "price": "19.2721", "applies": -11.49},
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppStyleConfig.themColor,
      body: ListView.builder(
        shrinkWrap: true, //为true可以解决子控件必须设置高度的问题
        physics: NeverScrollableScrollPhysics(),
        itemBuilder: (context, index) {
          if (index == 0) {
            return PhbTitleCellWidget(
              title1: "现货", title2: "最新价(USDT)", title3: "涨跌幅",);
          }
          return GestureDetector(onTap: () {
            HBRouter.navigateTo(context, AppRouters.currencyMarketPage,
                params: {"currency": dataSource[index - 1]["name"]});
          },
              child: ZfbCellWidget(
                dataModel: ZfbCellModel.fromJson(dataSource[index - 1]),
                showBottomBorder: index == dataSource.length ? false : true,));
        },
        itemCount: dataSource.length + 1,
      ),
    );
  }
}
